package com.example.dell.controllsmall.activity.db.manager;


import com.example.dell.controllsmall.activity.dao.UserInfo;
import com.example.dell.controllsmall.activity.db.UserInfoDao;
import com.example.dell.controllsmall.activity.db.base.BaseManager;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.query.Query;

import java.util.List;

/**
 * Created by zhangyuanyuan on 2017/9/28.
 */

public class UserInfoDbManager extends BaseManager<UserInfo, Long> {
    @Override
    public AbstractDao<UserInfo, Long> getAbstractDao() {
        return daoSession.getUserInfoDao();
    }

    public List<UserInfo> queryVoiceByQuestion(String question) {
        Query<UserInfo> build = null;
        try {
            build = getAbstractDao().queryBuilder()
                    .where(UserInfoDao.Properties.Name.eq(question))
                    .build();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return build.list();
    }

    public List<UserInfo> queryVoiceById(long id) {
        Query<UserInfo> build = null;
        try {
            build = getAbstractDao().queryBuilder()
                    .where(UserInfoDao.Properties.Id.eq(id))
                    .build();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return build.list();
    }
}
